package com.label.mapper;

import com.label.entity.labelbind;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.sql.Wrapper;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Jianhua
 * @since 2022-03-27
 */
@Repository
public interface LabelbindMapper extends BaseMapper<labelbind> {
    /**
     * 根据用户id查询所有的标签
     */
    @Select("SELECT * FROM `labelbindvo` WHERE patientid = #{id} and limitstate=1")
//    根据标签id一对一绑定标签信息
    @Results( {
            @Result(id = true, property = "limitid", column = "limitid"),
            @Result(property = "labels",column = "labelid",
                    one = @One(select = "com.label.mapper.LabelsMapper.getlabelbyid"))
    })
    List<labelbind> findlabelsByUserId(Integer id);
    /**
     * 根据id查询标签绑定信息
     */
    @Select("SELECT * FROM `labelbindvo` WHERE limitid = #{id} and limitstate=1")
//    根据标签id一对一绑定标签信息
    @Results( {
            @Result(id = true, property = "limitid", column = "limitid"),
            @Result(property = "labels",column = "labelid",
                    one = @One(select = "com.label.mapper.LabelsMapper.getlabelbyid"))
    })
    labelbind getlabelsById(Integer id);
}
